/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import { isString } from 'lodash';
/**
 * 隐藏主要字段
 */
export function importFieldHide(str: string, start = 0, end = str.length, replaceBy = '*') {
  if (!str || !isString(str)) {
    return str;
  }
  let text = '';
  const replaceTextLength = str.slice(start, end).length;
  while (text.length < replaceTextLength) {
    text += replaceBy;
  }

  return `${str.slice(0, start)}${text}${str.slice(end)}`;
}
